<?php   

class AppController extends Zend_Controller_Action
{
   	protected $logger; 
   	protected $objOpLogger ;
   	protected $objErrorLogger ;
   	
   	function init() 
   	{  
        $this->logger = Zend_Registry::get('logger');
        $this->logger->setClass(get_class($this));
        $this->objOpLogger = new Cts_Log_Operation( Zend_Registry::get('db') ) ;
        $this->objErrorLogger = new Cts_Log_Error( Zend_Registry::get('db') ) ;               
    }
        
    /**
     * Default actions
     *
     */
    
    public function indexAction()
    {
        $this->listAction();
    }    
	
	public function writeOpLog( $strResult , $strClassName , $strFunctionName )
	{
	    $aClassName = explode( '_' , $strClassName ) ;
	    if( Zend_Registry::isRegistered('nLoginId') )
        {
            $nUserId = Zend_Registry::get('nLoginId') ;
        }
        else
        {
            $nUserId = 0 ;    
        }
	    $this->objOpLogger->setOperationLog( $nUserId , $aClassName[0] , $strFunctionName ) ;
	    $this->objOpLogger->crit( $strResult ) ;
	}
	
	public function writeErrLog( $strErrorMessage , $strClassName , $strFunctionName , $strErrorTrace )
	{
	    $aClassName = explode( '_' , $strClassName ) ;
	    if( Zend_Registry::isRegistered('nLoginId') )
        {
            $nUserId = Zend_Registry::get('nLoginId') ;
        }
        else
        {
            $nUserId = 0 ;    
        }
	    $this->objErrorLogger->setErrorLog( $nUserId , $aClassName[0] , $strFunctionName , $strErrorTrace ) ;
	    $this->objErrorLogger->err( $strErrorMessage ) ;  
	}
}